{% extends "base.html" %}
{% block page_title %}WeJudge 账号授权系统 - 登录请求{% endblock %}
{% block page_body %}
    <div class="page_container">
            <div class="panel panel-success" style="max-width: 400px; width: 80%; margin: 0 auto">
                <div class="panel-heading">
                    <span class="panel-title">应用授权</span>
                    <span style="float:right">
                        {% if user != None %}
                            {{ user.nickname }}
                            {% if force_login %}
                            <a href="javascript:void(0)" onclick="start_login()">[切换账号]</a>
                            {% endif %}
                        {% else %}
                            <a href="javascript:void(0)" onclick="start_login()">请先登录</a>
                        {% endif %}
                    </span>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-sm-4" align="center">
                            {% if user == None %}
                                <img src="/static/images/headimg_placeholder.png" width="80" height="80">
                            {% else %}
                                <img src="{% if user.headimg == None or user.headimg == '' %}/static/images/headimg_placeholder.png{% else %}/resource/headimg/{{ user.headimg }}{% endif %}" width="80" height="80">
                            {% endif %}
                        </div>
                        <div class="col-sm-4" align="center">
                             <img src="/static/images/connect.png" width="80" height="80">
                        </div>
                        <div class="col-sm-4" align="center">
                            <img src="{% if app.avatar == '' %}/static/images/headimg_placeholder.png{% else %}{{ app.avatar }}{% endif %}" width="80" height="80">
                        </div>
                    </div>
                    <br />
                    <div align="center">
                        <h3>{{ app.appname }}
                            <br >
                            <small>{{ app.description }}</small>
                        </h3>
                    </div><br />
                    <div class="alert alert-warning">
                        您的操作将会授权此应用获取以下信息
                        <ul>
                            <li>账号基本信息</li>
                            <li>账号详细资料</li>
                        </ul>
                    </div>
                    <form action="?{{ urlcall }}" method="post">
                        <input type="hidden" name="confirm" value="1">
                        <button class="btn btn-block btn-success" {% if not user_logined %}disabled{% endif %}>确定授权</button>
                    </form><br />
{#                    <form action="?{{ urlcall }}" method="post">#}
{#                        <input type="hidden" name="confirm" value="0">#}
{#                        <button class="btn btn-block btn-danger" {% if not user_logined %}disabled{% endif %}>取消授权</button>#}
{#                    </form>#}
                </div>
            </div>
    </div>
{% endblock %}
{% block  page_script %}

<script type="text/javascript">
    function start_login() {
        {% if force_login %}
        var action = 'oauth2_forcelogin';
        {% else %}
        var action = '';
        {% endif %}
        WeJudge.login_request_dialog(action);
    }
    {% if not user_logined %}
    $(function () {
       start_login();
    });
    {% endif %}
</script>
{% endblock %}